package com.qianfeng.smsplatform.search.service.impl;

/**
 * @author fjw
 * @version 1.0
 * @date 2019/12/3 10:29
 */

import com.qianfeng.smsplatform.common.constants.CacheConstants;
import com.qianfeng.smsplatform.common.model.Standard_Submit;
import com.qianfeng.smsplatform.search.feign.MyFeign;
import com.qianfeng.smsplatform.search.service.FilterChain;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * todo  黑名单过滤器
 */
@Component
@Slf4j
public class SmsBlackFilter implements FilterChain {

    @Autowired
    private MyFeign myFeign;

    @Override
    public boolean doFilter(Standard_Submit submit) {
        log.info("执行了黑名单过滤器");
        //查询下是否为黑名单 这是目标手机号
        String destMobile = submit.getDestMobile();
        // 从缓存中查询 黑名单 号码
        String s = myFeign.getBlackMenu(CacheConstants.CACHE_PREFIX_BLACK + destMobile);
        if (s.equals("1")){
            //说明是黑名单 返回false  下面的过滤器不执行了



            return false;
        }
        return true;
    }
}
